package com.huabo.contract.service.impl;

import com.hbfk.util.PageInfo;
import com.huabo.contract.config.DateBaseConfig;
import com.huabo.contract.oracle.entity.TblOrgBankaccount;
import com.huabo.contract.oracle.mapper.TblOrgBankaccountMapper;
import com.huabo.contract.service.TblOrgBankAccountService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

@Service
public class TblOrgBankAccountServiceImpl implements TblOrgBankAccountService {

    @Resource
    private TblOrgBankaccountMapper tblOrgBankaccountMapper;

    @Override
    public void findListByPageInfo(PageInfo<TblOrgBankaccount> pageInfo, TblOrgBankaccount bank) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            Map<String, Object> resultMap = new HashMap<String, Object>(0);
            pageInfo.setTlist(tblOrgBankaccountMapper.findPlanNodeListForCollection(pageInfo, bank));
            pageInfo.setTotalRecord(tblOrgBankaccountMapper.selectCountByPageInfoCount(bank));
            resultMap.put("code", "1");
            resultMap.put("msg", "访问接口成功");
            resultMap.put("pageInfo", pageInfo);
        } else {
            Map<String, Object> resultMap = new HashMap<String, Object>(0);
            pageInfo.setTlist(tblOrgBankaccountMapper.findPlanNodeListForCollection(pageInfo, bank));
            pageInfo.setTotalRecord(tblOrgBankaccountMapper.selectCountByPageInfoCount(bank));
            resultMap.put("code", "1");
            resultMap.put("msg", "访问接口成功");
            resultMap.put("pageInfo", pageInfo);
        }
    }

    @Override
    public void findListPageInfo(PageInfo<TblOrgBankaccount> pageInfo, TblOrgBankaccount bank) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            Map<String, Object> resultMap = new HashMap<String, Object>(0);
            pageInfo.setTlist(tblOrgBankaccountMapper.findListPageInfo(pageInfo, bank));
            pageInfo.setTotalRecord(tblOrgBankaccountMapper.findListPageInfocount(bank));
            resultMap.put("code", "1");
            resultMap.put("msg", "访问接口成功");
            resultMap.put("pageInfo", pageInfo);
        } else {
            Map<String, Object> resultMap = new HashMap<String, Object>(0);
            pageInfo.setTlist(tblOrgBankaccountMapper.findListPageInfo(pageInfo, bank));
            pageInfo.setTotalRecord(tblOrgBankaccountMapper.findListPageInfocount(bank));
            resultMap.put("code", "1");
            resultMap.put("msg", "访问接口成功");
            resultMap.put("pageInfo", pageInfo);
        }
    }

    @Override
    public TblOrgBankaccount findById(Integer bankId) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            return tblOrgBankaccountMapper.findByBanId(bankId);
        } else {
            return tblOrgBankaccountMapper.findByBanId(bankId);
        }
    }

    @Override
    public void findListByPageInfoPid(PageInfo<TblOrgBankaccount> pageInfo, BigDecimal pid,TblOrgBankaccount bank) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            Map<String, Object> resultMap = new HashMap<String, Object>(0);
            pageInfo.setTlist(tblOrgBankaccountMapper.findListByPageInfoPid(pageInfo, pid, bank));
            pageInfo.setTotalRecord(tblOrgBankaccountMapper.findListByPageInfoPidCount(pid, bank));
            resultMap.put("code", "1");
            resultMap.put("msg", "访问接口成功");
            resultMap.put("pageInfo", pageInfo);
        } else {
            Map<String, Object> resultMap = new HashMap<String, Object>(0);
            pageInfo.setTlist(tblOrgBankaccountMapper.findListByPageInfoPid(pageInfo, pid, bank));
            pageInfo.setTotalRecord(tblOrgBankaccountMapper.findListByPageInfoPidCount(pid, bank));
            resultMap.put("code", "1");
            resultMap.put("msg", "访问接口成功");
            resultMap.put("pageInfo", pageInfo);
        }
    }

    @Override
    public TblOrgBankaccount findByBankId(BigDecimal bankid) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            return tblOrgBankaccountMapper.findByBankId(bankid);
        } else {
            return tblOrgBankaccountMapper.findByBankId(bankid);
        }
    }

    @Override
    public void UpdateModifyBankInfo(TblOrgBankaccount oldEntity) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            tblOrgBankaccountMapper.UpdateModifyBankInfo(oldEntity);
        } else {
            tblOrgBankaccountMapper.UpdateModifyBankInfo(oldEntity);
        }
    }

    @Override
    public void savebankInfo(TblOrgBankaccount bank) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            tblOrgBankaccountMapper.savebankInfo(bank);
        } else {
            tblOrgBankaccountMapper.savebankInfo(bank);
        }
    }

    @Override
    public String removeOrgBankInfo(Integer bankId) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            return tblOrgBankaccountMapper.removeOrgBankInfo(bankId);
        } else {
            return tblOrgBankaccountMapper.removeOrgBankInfo(bankId);
        }
    }
}
